package com.orange.quickback.system.service.user.manage.impl;

import com.orange.quickback.system.api.common.result.QBootResult;
import com.orange.quickback.system.dao.user.manage.QBootRoleMenuRepository;
import com.orange.quickback.system.dao.user.manage.QBootRoleRepository;
import com.orange.quickback.system.service.user.manage.QBootRolesService;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class QBootRolesServiceImpl implements QBootRolesService {
    @Resource
    QBootRoleMenuRepository qBootRoleMenuRepository;

    @Resource
    QBootRoleRepository qBootRoleRepository;
    @Override
    public QBootResult getAllRolesMenu(int page, int size) {
        PageRequest pageRequest = PageRequest.of(page,size);
        return QBootResult.build(qBootRoleMenuRepository.findAll(pageRequest));
    }

    @Override
    public QBootResult getAllRoles() {
        return QBootResult.build(qBootRoleRepository.findAll());
    }

    @Override
    public QBootResult deleteRolesMenuById(Long id) {
        try{
            qBootRoleMenuRepository.deleteById(id);
            return QBootResult.build("删除成功");
        }catch (Exception e) {
            return QBootResult.build("删除失败");
        }
    }
}
